home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Point_Rect C++ Classes / MacObj.sit / MacObj ƒ / CRect.cp < prev    next >
Text File  |  1993-09-11  |  3KB  |  107 lines

  1. #ifdef _MACOBJ_SPEED
  2. #define _MACOBJ_INLINE inline
  3. #else
  4. #define _MACOBJ_INLINE
  5. #include "CRect.h"
  6. #endif
  7.  
  8. _MACOBJ_INLINE CRect::CRect()
  9. { }
  10.  
  11. _MACOBJ_INLINE CRect::CRect(short l, short t, short r, short b)
  12. { top = t; left = l; bottom = b; right = r; }
  13.  
  14. _MACOBJ_INLINE CRect::CRect(const Rect& r)
  15. { *(Rect*)this = r; }
  16.  
  17. _MACOBJ_INLINE void CRect::SetRect(short left, short top, short right, short bottom)
  18. { ::SetRect(this, left, top, right, bottom); }
  19.  
  20. _MACOBJ_INLINE void CRect::SetRectEmpty()
  21. { ::SetRect(this,0,0,0,0); };
  22.  
  23. _MACOBJ_INLINE void CRect::InsetRect(short x, short y)
  24. { ::InsetRect(this,x,y); }
  25.  
  26. _MACOBJ_INLINE void CRect::OffsetRect(short x, short y)
  27. { ::OffsetRect(this,x,y); }
  28.  
  29. _MACOBJ_INLINE void CRect::OffsetRect(Point p)
  30. { ::OffsetRect(this, p.h, p.v); }
  31.  
  32. _MACOBJ_INLINE Boolean CRect::PtInRect(Point p)
  33. { return ::PtInRect(p, this); }
  34.  
  35. _MACOBJ_INLINE Boolean CRect::EmptyRect() const
  36. { return ::EmptyRect(this); }
  37.  
  38. _MACOBJ_INLINE Boolean CRect::NullRect() const
  39. { return (top == 0 && left == 0 &&
  40.     bottom == 0 && right == 0); }
  41.  
  42. _MACOBJ_INLINE short CRect::Height(void)
  43. { return bottom - top; }
  44.  
  45. _MACOBJ_INLINE short CRect::Width(void)
  46. { return right - left; }
  47.  
  48. _MACOBJ_INLINE Boolean CRect::EqualRect(const Rect& r) const 
  49. { return ::EqualRect(this, &r); }
  50.  
  51. _MACOBJ_INLINE CPoint& CRect::TopLeft()
  52. { return *(CPoint*)this; }
  53.  
  54. _MACOBJ_INLINE CPoint& CRect::BottomRight()
  55. { return *((CPoint*)this+1); }
  56.  
  57. _MACOBJ_INLINE void CRect::UnionRect(Rect& r1, Rect& r2)
  58. { ::UnionRect(&r1,&r2,this); };
  59.  
  60. _MACOBJ_INLINE void CRect::SectRect(Rect& r1, Rect& r2)
  61. { ::SectRect(&r1,&r2,this); };
  62.  
  63. _MACOBJ_INLINE void CRect::operator=(const Rect& r)
  64. { (*(Rect*)this) = r; }
  65.  
  66. _MACOBJ_INLINE Boolean CRect::operator==(const Rect& r) const
  67. { return ::EqualRect(this, &r); }
  68.  
  69. _MACOBJ_INLINE Boolean CRect::operator!=(const Rect& r) const
  70. { return !::EqualRect(this, &r); }
  71.  
  72. _MACOBJ_INLINE void CRect::operator+=(Point p)
  73. { ::OffsetRect(this,p.h,p.v); }
  74.  
  75. _MACOBJ_INLINE void CRect::operator-=(Point p)
  76. { ::OffsetRect(this,-p.h,-p.v); }
  77.  
  78. _MACOBJ_INLINE void CRect::operator&=(const Rect& r)
  79. { ::SectRect(this,&r,this); }
  80.  
  81. _MACOBJ_INLINE void CRect::operator|=(const Rect& r)
  82. { ::UnionRect(this,&r,this); }
  83.  
  84. _MACOBJ_INLINE CRect CRect::operator+(Point p) const
  85. { CRect r(*this); ::OffsetRect(&r, p.h, p.v); return r; }
  86.  
  87. _MACOBJ_INLINE CRect CRect::operator-(Point p) const
  88. { CRect r(*this); ::OffsetRect(&r, -p.h, -p.v); return r; }
  89.  
  90. _MACOBJ_INLINE CRect CRect::operator|(const Rect& r) const
  91. { CRect r1; ::UnionRect(&r, this, &r1); return r1; }
  92.  
  93. _MACOBJ_INLINE CRect CRect::operator&(const Rect& r) const
  94. { CRect r1; ::SectRect(&r, this, &r1); return r1; }
  95.  
  96. _MACOBJ_INLINE void CRect::EraseRect()
  97. { ::EraseRect(this); }
  98.  
  99. _MACOBJ_INLINE void CRect::FillRect(PatPtr thePat)
  100. { ::FillRect(this, (const unsigned char*)thePat); }
  101.  
  102. _MACOBJ_INLINE void CRect::FrameRect()
  103. { ::FrameRect(this); }
  104.  
  105. _MACOBJ_INLINE void CRect::InvertRect()
  106. { ::InvertRect(this); }
  107.